package com.teradata.params.core.model;

public enum PrimitiveTypeKind {
    //如果打算自定义自己的方法，那么必须在enum实例序列的最后添加一个分号。而且 Java 要求必须先定义 enum 实例。
    Binary("BINARY",1),
    Boolean("BOOLEAN",2),
    Byte("BYTE",3),
    SByte("SBYTE",4),
    Date("DATE",5),
    DateTimeOffset("DATETIMEOFFSET",6),
    TimeOfDay("TIMEOFDAY",7),
    Duration("DURATION",8),
    Decimal("DECIMAL",9),
    Single("SINGLE",10),
    Double("DOUBLE",11),
    Guid("GUID",12),
    Int16("INT16",13),
    Int32("INT32",14),
    Int64("INT64",15),
    String("STRING",16),
    Stream("STREAM",17);

    // 成员变量
    private String name;
    private int index;
    // 构造方法
    private PrimitiveTypeKind(String name, int index) {
        this.name = name;
        this.index = index;
    }
    // 普通方法
    public static String getName(int index) {
        for (PrimitiveTypeKind c : PrimitiveTypeKind.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return null;
    }
    // get set 方法
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getIndex() {
        return index;
    }
    public void setIndex(int index) {
        this.index = index;
    }

    //覆盖方法
    @Override
    public String toString() {
        return this.name;
    }
}
